package com.taldh.design.patterns.factories.simple;

import java.util.HashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * date: 2020/5/24
 *
 * @author 袁小黑
 * @version 1.0.0
 */

public interface WeaponFactoryBetterImpl {

    /**
     * Creates an instance of the given type.
     *
     * @param name representing enum of an object type to be created.
     * @return new instance of a requested class implementing {@link Weapon} interface.
     */
    Weapon create(WeaponType name);

    /**
     * Creates factory - placeholder for specified {@link Builder}s.
     *
     * @param consumer for the new builder to the factory.
     * @return factory with specified {@link Builder}s
     */
//    static WeaponFactory factory(Consumer<Builder> consumer) {
//        var map = new HashMap<WeaponType, Supplier<Weapon>>();
//        consumer.accept(map::put);
//        return name -> map.get(name).get();
//    }

}
